//###############
// FILE : FileSearcher.java
// WRITER : Lior Zimmerman liorz06 066462300
// WRITER : Ohad Dan ohad_dan 036767960
// EXERCISE : oop ex3 2008
// DESCRIPTION: Abstract representation of searching for data in file content.
//###############
package oop.ex3.fileSearchModel.SearchEngine;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;

import oop.ex3.fileSearchModel.filters.*;
import oop.ex3.fileSearchModel.filters.Conditionable.STATUS;
/**
 * Abstract representation of searching for data in file content.
 */
public abstract class FileSearcher {
	//***********************************************************************
	//  Data members :                                                      *
	//***********************************************************************
    protected ArrayList<? extends Filter> _keywords;
    protected File _file;
  
    //***********************************************************************
	//  Methods :                                                           *
	//***********************************************************************
    /**
     * Construct a new file search.
     * @param file the file in which the test will be made.
     */
    public FileSearcher( File file ) {
        _file = file;
    }
    /**
     * Sets all nodes status.
     * @param keywords Nodes to be set.
     * @param status The status to be set.
     */
    protected void setNodesStatus( ArrayList<? extends Filter> keywords,
            STATUS status) {
        Iterator<? extends Filter> it = keywords.iterator();
        _keywords = keywords;
        while ( it.hasNext() ) {
            Filter node = it.next();
            node.setCondition(status);
        }
    }
    /**
     * Close stream.
     * @throws IOException in case of an error of closing the stream.
     */
    public abstract void close() throws IOException;
    /**
     * Sets the status of the content filters.
     * @return True if there are content filters left which their
     * content was not found else otherwise.
     * @throws IOException in case of an error of closing the stream.
     */
    public abstract boolean startSearch() throws IOException;
        
}
